<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                template="/WEB-INF/template/template.xhtml">

    <ui:define name="Content">

        <ui:param name="bean" value="#{atividadeMBean}" />

        <p:fieldset legend="Editando 'Atividades'">  
            <h:form id="view" prependId="false">

                <p:panel> 
                    <p:editor value="#{bean.selectedAtividade.texto}" id="TextEditorId" widgetVar="TextEditor" required="true"/> 

                    <f:facet name="footer">
                        <p:commandButton value="Salvar" onclick="saveConfirm.show()"
                                         icon="ui-icon-check" />
                        
                        <p:commandButton value="Voltar" action="/atividades?faces-redirect=true"
                                         icon="ui-icon-check" global="false"/>
                    </f:facet>
                </p:panel>  

            </h:form>
        </p:fieldset>

        <p:confirmDialog id="saveConfirmId" message="Are you sure you want to save this?" 
                         header="Confirmation" widgetVar="saveConfirm" appendToBody="true" severity="alert">
            <h:form>
                <p:commandButton value="No" onsuccess="saveConfirm.hide()" icon="ui-icon-cancel" 
                                 style="float: right;" global="false"/>

                <p:commandButton value="Yes" update=":view" oncomplete="saveConfirm.hide()"
                                 action="#{bean.update}" icon="ui-icon-check" style="float: right;" />
            </h:form>
        </p:confirmDialog>

    </ui:define>
</ui:composition>
